<template>
  <component :is="iconComponent" v-if="iconComponent" />
</template>

<script setup>
const props = defineProps({
  icon: {
    type: String,
    required: true,
  },
});

const iconComponent = computed(() => {
  if (!props.icon) return null;

  const iconName = `i-ep-${props.icon.toLowerCase()}`;
  try {
    return resolveComponent(iconName);
  } catch {
    console.warn(`图标 ${iconName} 未找到`);
    return null;
  }
});
</script>
